package com.example.allshengmedical.experimentanalyze.activity;

import java.io.BufferedReader;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.FileReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.lang.reflect.Type;
import java.text.DecimalFormat;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Date;
import java.util.HashMap;
import java.util.HashSet;
import java.util.List;

import android.R.integer;
import android.R.string;
import android.app.ProgressDialog;
import android.content.Intent;
import android.graphics.Color;
import android.graphics.drawable.BitmapDrawable;
import android.os.Environment;
import android.os.Handler;
import android.os.Message;
import android.text.Selection;
import android.text.TextUtils;
import android.util.Log;
import android.view.Gravity;
import android.view.LayoutInflater;
import android.view.MotionEvent;
import android.view.View;
import android.view.ViewGroup;
import android.view.View.OnClickListener;
import android.view.View.OnTouchListener;
import android.view.ViewGroup.LayoutParams;
import android.widget.AdapterView;
import android.widget.AdapterView.OnItemClickListener;
import android.widget.BaseAdapter;
import android.widget.Button;
import android.widget.EditText;
import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.PopupWindow;
import android.widget.RelativeLayout;
import android.widget.SeekBar;
import android.widget.SeekBar.OnSeekBarChangeListener;
import android.widget.TextView;

import com.example.allshengmedical.R;
import com.example.allshengmedical.R.color;
import com.example.allshengmedical.base.BaseActivity;
import com.example.allshengmedical.base.BaseApplication;
import com.example.allshengmedical.experimentanalyze.presenter.AnalyzeRawDataPresenter;
import com.example.allshengmedical.experimentanalyze.view.IAnalyzeRawDataView;
import com.example.allshengmedical.experimentnew.bean.MethodBean;
import com.example.allshengmedical.experimentrun.activity.TemparetureActivity;
import com.example.allshengmedical.mainmenu.activity.MainMenuActivity;
import com.example.allshengmedical.util.ByAlert;
import com.example.allshengmedical.util.DragGridView;
import com.example.allshengmedical.util.FileParsingUtil;
import com.example.allshengmedical.util.LogUtil;
import com.example.allshengmedical.util.SharedPreferencesUtils;
import com.github.mikephil.charting.charts.LineChart;
import com.github.mikephil.charting.components.Legend;
import com.github.mikephil.charting.components.XAxis;
import com.github.mikephil.charting.components.Legend.LegendForm;
import com.github.mikephil.charting.data.Entry;
import com.github.mikephil.charting.data.LineData;
import com.github.mikephil.charting.data.LineDataSet;
import com.google.gson.Gson;
import com.google.gson.reflect.TypeToken;

//原始数据界面
public class AnalyzeRawDataActivity extends BaseActivity implements IAnalyzeRawDataView, OnClickListener {
	public final int TASK_LOOP_COMPLETE = 0;
	ProgressDialog pd;
	AnalyzeRawDataPresenter rawDataPresenter;

	// bar
	private boolean menuboo;
	private PopupWindow menuPopupWindow;
	// lineChart
	LineChart chart;
	// 曲线
	private LineDataSet dataSet = new LineDataSet(null, "");

	private ArrayList<LineDataSet> dataSets;

	private ArrayList<String> xValues;

	// 基因盘的数据
	public List<HashMap<String, Object>> dataSourceListBlock1 = new ArrayList<HashMap<String, Object>>();
	public List<HashMap<String, Object>> dataSourceListBlock2 = new ArrayList<HashMap<String, Object>>();
	public List<HashMap<String, Object>> dataSourceListBlockToShow = new ArrayList<HashMap<String, Object>>();
	private DragGridView dragGridView;
	private DragGridViewAdapter dragGridViewAdapter;

	// block
	private String blockStr = "block1";
	private Button block1Btn, block2Btn;
	private TextView blockUpTv, blockDownTv;
	// show
	LinearLayout toolLine, blockLine, geneLine;
	TextView showTv;
	Boolean showBoolean = true;

	// seekBar
	SeekBar seekBar;
	TextView seekBarNameTv, subTv, numTv, addTv;

	// 数据
	String folderName;
	String fileName;
	private String appFilePath = Environment.getExternalStorageDirectory() + "/" + "AllShengMedical";
	StringBuffer contextString = new StringBuffer();

	HashMap<Integer, Integer> pointMap = new HashMap();
	List<HashMap<String, Object>> pointMaps = new ArrayList<HashMap<String, Object>>();

	// private FileParsingUtil fileParsingUtil;
	private RawDataUtil rawdataUtil;
	private TextView clearTv;

	RelativeLayout white_line;
	
	private ArrayList<MethodBean> activityMethodBeans = new ArrayList<MethodBean>();

	@Override
	protected int setcontent() {
		return R.layout.activity_analyze_rawdata;
	}

	@Override
	protected void initView() {
		dragGridView.setDrag(false);
		rawDataPresenter = new AnalyzeRawDataPresenter(this);

		rawDataPresenter.initBottomView();
		rawDataPresenter.initLineChart();
		rawDataPresenter.initDragGridView();
		rawDataPresenter.initSeekBar();
		getinfo();
		rawDataPresenter.initAppHead();

		numTv.setOnClickListener(new OnClickListener() {

			@Override
			public void onClick(View v) {
				numberKeyBoardPopupWindow(v, numTv, false);

			}
		});

		clearTv.setOnClickListener(new OnClickListener() {

			@Override
			public void onClick(View v) {
				for (HashMap<String, Object> bean : dataSourceListBlock1) {
					bean.put("item_selected", false);
				}
				for (HashMap<String, Object> bean : dataSourceListBlock2) {
					bean.put("item_selected", false);
				}

				dragGridViewAdapter.notifyDataSetChanged();
				dataSets.clear();
				LineData lineData = new LineData(xValues, dataSets);
				// mLineChart2.setBackgroundColor(Color.BLUE);
				chart.setGridBackgroundColor(Color.WHITE);
				// 将数据插入
				chart.setData(lineData);
				Legend mLegend = chart.getLegend(); //
				// 设置比例图标示，就是那个一组y的value的
				mLegend.setXEntrySpace(7f);
				mLegend.setYEntrySpace(5f);
				chart.animateX(0); // 立即执行的动画,x轴

			}
		});

	}

	private void getinfo() {

		//
		folderName = SharedPreferencesUtils.get(AnalyzeRawDataActivity.this,
				BaseApplication.FILEMANGER_PREPAREFOLDERPATH, "") + "";
		fileName = SharedPreferencesUtils.get(AnalyzeRawDataActivity.this,
				BaseApplication.FILEMANGER_PREPAREFILENAME, "") + "";

		String path = appFilePath + "/" + folderName;

		File file = new File(path + "/" + fileName);

		FileInputStream in = null;
		BufferedReader reader = null;
		contextString = new StringBuffer();
		try {
			in = new FileInputStream(file);
			reader = new BufferedReader(new InputStreamReader(in));
			String line = "";
			while ((line = reader.readLine()) != null) {
				contextString.append(line);
				contextString.append(",");
			}
		} catch (FileNotFoundException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		} catch (IOException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		} finally {
			if (reader != null) {
				try {
					reader.close();
				} catch (Exception e2) {
					e2.printStackTrace();
				}
			}
		}

		// BufferedReader reader = null;
		// contextString=new StringBuffer();
		// try {
		// System.out.println("以行为单位读取文件内容，一次读一整行:");
		// reader = new BufferedReader(new FileReader(file));
		// String tempString = null;
		// int line = 1;
		// // 一次读入一行，直到读入null为文件结束
		// while ((tempString = reader.readLine()) != null) {
		// // 显示行号
		// // System.out.println("line " + line + ": " + tempString);
		// // Log.e("--", tempString);
		// contextString.append(tempString);
		// contextString.append(",");
		// line++;
		// }
		// reader.close();
		// } catch (IOException e) {
		// e.printStackTrace();
		// } finally {
		// if (reader != null) {
		// try {
		// reader.close();
		// // LogUtil.e("!!", contextString + "");
		//
		// } catch (IOException e1) {
		// }
		// }
		// }
		// PassReference
		String passReference = "";
		String passReferenceNum = "-1";
		passReference = contextString.substring(contextString.indexOf("PassReference:") + 14,
				contextString.indexOf(",,Aisle:"));
		if (!TextUtils.isEmpty(passReference)) {
			// 如果不为空
			// data_list.add("FAM");
			// data_list.add("SYBR Green I");
			// data_list.add("ROX");
			// data_list.add("TEXAS-RED");
			// data_list.add("HEX");
			// data_list.add("JOE");
			// data_list.add("CY3");
			// data_list.add("TET");
			// data_list.add("CY5");
			if (passReference.equals("FAM")) {
				passReferenceNum = "1";
			} else if (passReference.equals("SYBR Green I")) {
				passReferenceNum = "1";
			} else if (passReference.equals("ROX")) {
				passReferenceNum = "3";
			} else if (passReference.equals("TEXAS-RED")) {
				passReferenceNum = "3";
			} else if (passReference.equals("HEX")) {
				passReferenceNum = "2";
			} else if (passReference.equals("JOE")) {
				passReferenceNum = "2";
			} else if (passReference.equals("CY3")) {
				passReferenceNum = "2";
			} else if (passReference.equals("TET")) {
				passReferenceNum = "2";
			} else if (passReference.equals("CY5")) {
				passReferenceNum = "4";
			}

		}

		int index = 0;
		// 上面解析
		while (!(contextString.indexOf("steptType:", index) <= 0)) {

			// steptType:
			String steptType;
			steptType = contextString.substring(contextString.indexOf("steptType:", index) + 10,

					contextString.indexOf(",temperature:", index));

			// LogUtil.e(steptType);

			// temperature
			String temperature;
			temperature = contextString.substring(contextString.indexOf(",temperature:", index) + 13,

					contextString.indexOf(",time:", index));

			// LogUtil.e(temperature);
			// time
			String time;
			time = contextString.substring(contextString.indexOf(",time:", index) + 6,

					contextString.indexOf(",goTo:", index));
					// LogUtil.e(time);

			// goTo
			String goTo;
			goTo = contextString.substring(contextString.indexOf(",goTo:", index) + 6,

					contextString.indexOf(",Repititions:", index));
			// LogUtil.e(goTo);
			// Repititions
			String repititions;
			repititions = contextString.substring(contextString.indexOf(",Repititions:", index) + 13,

					contextString.indexOf(",deltaT:", index));
			// LogUtil.e(repititions);
			// deltaT
			String deltaT;
			deltaT = contextString.substring(contextString.indexOf(",deltaT:", index) + 8,

					contextString.indexOf(",rightSelect:", index));
			// LogUtil.e(deltaT);

			int nextIndex = contextString.indexOf("steptType:", index) + 10;

			// rightSelect
			String rightSelect;

			if (contextString.indexOf(",steptType:", nextIndex) < 0) {
				rightSelect = contextString.substring(contextString.indexOf(",rightSelect:", index) + 13,
						contextString.indexOf(",,pointMap", index));
				if ("null".equals(rightSelect)) {
					rightSelect = "";
				}

			} else {
				rightSelect = contextString.substring(contextString.indexOf(",rightSelect:", index) + 13,

						contextString.indexOf(",steptType:", nextIndex));
				if ("null".equals(rightSelect)) {
					rightSelect = "";
				}
			}
			// LogUtil.e(rightSelect);
			index = contextString.indexOf(",rightSelect:", index) + 13;

			activityMethodBeans.add(new MethodBean(steptType.trim(), temperature.trim(), time.trim(), goTo.trim(),
					repititions.trim(), deltaT.trim()));
		}
		// 获取重复次数

		int stepNum = Integer.parseInt(contextString
				.substring(contextString.indexOf(",readDataString: ") + 17, contextString.indexOf(",,Methods")).trim());
//		getRepititions(stepNum);
		// repititions = Integer.parseInt(activityMethodBeans.get(stepNum -
		// 1).getRepititions());
	}

	@Override
	protected void initData() {
		// TODO Auto-generated method stub

	}

	@Override
	public void initAppHead() {
		setActionBar();
		setSystemTime();
	}

	@Override
	public void initBottomView() {
		// setBottomView();

	}

	@Override
	public void initLineChart() {
		XAxis xAxis = chart.getXAxis();

		// 设置X轴的文字在底部
		xAxis.setPosition(XAxis.XAxisPosition.BOTTOM);

		// 设置描述文字
		chart.setDescription("");

		xValues = new ArrayList<String>();
		// for (int i = 1; i < 4; i++) {
		// xValues.add(i + "");
		// }
		xValues.add("channel1");
		xValues.add("channel2");
		xValues.add("channel3");
		xValues.add("channel4");

		Log.e("wing", xValues.size() + "");

		// 模拟一组y轴数据(存放y轴数据的是一个Entry的ArrayList) 他是构建LineDataSet的参数之一

		ArrayList<Entry> yValue = new ArrayList<Entry>();

		// 模拟第二组组y轴数据(存放y轴数据的是一个Entry的ArrayList) 他是构建LineDataSet的参数之一

		// ArrayList<Entry> yValue1 = new ArrayList<Entry>();

		Log.e("wing", yValue.size() + "");

		// 构建一个LineDataSet 代表一组Y轴数据 （比如不同的彩票： 七星彩 双色球）

		dataSets = new ArrayList<LineDataSet>();

		// 将数据加入dataSets

		// 构建一个LineData 将dataSets放入
		LineData lineData = new LineData(xValues, dataSets);

		// mLineChart2.setBackgroundColor(Color.BLUE);
		chart.setGridBackgroundColor(Color.WHITE);
		// 将数据插入
		chart.setData(lineData);
		chart.removeAllViews();

		Legend mLegend = chart.getLegend(); // 设置比例图标示，就是那个一组y的value的
		mLegend.setXEntrySpace(7f);
		mLegend.setYEntrySpace(5f);
		mLegend.setForm(LegendForm.SQUARE);// 样式
		mLegend.setFormSize(0f);// 字体
		mLegend.setTextColor(Color.WHITE);// 颜色

		chart.animateX(0); // 立即执行的动画,x轴

	}

	private void getDataSourListBlock() {
		folderName = SharedPreferencesUtils.get(AnalyzeRawDataActivity.this,
				BaseApplication.FILEMANGER_PREPAREFOLDERPATH, "") + "";
		fileName = SharedPreferencesUtils.get(AnalyzeRawDataActivity.this, BaseApplication.FILEMANGER_PREPAREFILENAME,
				"") + "";

		String path = appFilePath + "/" + folderName;

		File file = new File(path + "/" + fileName);
		FileInputStream in = null;
		BufferedReader reader = null;
		contextString = new StringBuffer();
		try {
			in = new FileInputStream(file);
			reader = new BufferedReader(new InputStreamReader(in));
			String line = "";
			int lines = 0;
			while ((line = reader.readLine()) != null) {
				contextString.append(line);
				contextString.append(",");
				lines++;
				LogUtil.e(lines + "");
			}
		} catch (FileNotFoundException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		} catch (IOException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		} finally {
			if (reader != null) {
				try {
					reader.close();
				} catch (Exception e2) {
					e2.printStackTrace();
				}
			}
		}

		// BufferedReader reader = null;
		// contextString=new StringBuffer();
		// System.gc();
		// try {
		// System.out.println("以行为单位读取文件内容，一次读一整行:");
		// reader = new BufferedReader(new FileReader(file));
		// String tempString = null;
		// int line = 1;
		// // 一次读入一行，直到读入null为文件结束
		// while ((tempString = reader.readLine()) != null) {
		// // 显示行号
		// // System.out.println("line " + line + ": " + tempString);
		// // Log.e("--", tempString);
		// contextString.append(tempString);
		// contextString.append(",");
		// line++;
		// }
		// reader.close();
		// } catch (IOException e) {
		// e.printStackTrace();
		// } finally {
		// if (reader != null) {
		// try {
		// reader.close();
		// // LogUtil.e("!!", contextString + "");
		//
		// } catch (IOException e1) {
		// }
		// }
		// }
		int index = 0;

		for (int i = 0; i < 16; i++) {
			HashMap<String, Object> hashMap = new HashMap<String, Object>();
			String item_image = contextString.substring(contextString.indexOf("item_image:", index) + 11,
					contextString.indexOf(",item_text:", index)).trim();
			String item_text = contextString.substring(contextString.indexOf("item_text:", index) + 10,
					contextString.indexOf(",item_selected:", index)).trim();
			Boolean item_selected = Boolean.getBoolean(contextString.substring(
					contextString.indexOf("item_selected:", index) + 14, contextString.indexOf(",item_null:", index)));

			boolean item_null = false;
			if ("null".equals(contextString.substring(contextString.indexOf("item_null:", index) + 10,
					contextString.indexOf(",item_aisle:", index)))) {
				item_null = true;
				hashMap.put("item_null", item_null);
			} else {
				item_null = false;
				hashMap.put("item_null", item_null);
			}
			// = contextString.substring(
			// contextString.indexOf("item_null:", index) + 10,
			// contextString.indexOf(",item_aisle:", index));
			int item_aisle = 0;
			if ("null".equals(contextString.substring(contextString.indexOf("item_aisle:", index) + 11,
					contextString.indexOf(",item_type:", index)).trim())) {

			} else {
				item_aisle = Integer.parseInt(contextString.substring(contextString.indexOf("item_aisle:", index) + 11,
						contextString.indexOf(",item_type:", index)).trim());
			}

			// String item_type = contextString.substring(
			// contextString.indexOf("item_type:", index) + 11,
			// contextString.indexOf("item_type:", index));

			int nextIndex = contextString.indexOf("item_image:", index) + 11;

			String item_type = "";
			if (i == 15) {
				item_type = contextString.substring(contextString.indexOf("item_type:", index) + 10,
						contextString.indexOf(",,dataSourceListBlock2", index)).trim();

			} else {
				item_type = contextString.substring(contextString.indexOf("item_type:", index) + 10,
						contextString.indexOf(",item_image:", nextIndex)).trim();
			}

			LogUtil.e(item_image);
			LogUtil.e(item_text);
			LogUtil.e(item_selected);
			// LogUtil.e(item_null+"");
			// LogUtil.e(item_aisle+"");
			LogUtil.e(item_type);

			hashMap.put("item_image", item_image);
			hashMap.put("item_text", item_text);
			hashMap.put("item_selected", item_selected);

			hashMap.put("item_aisle", item_aisle);
			hashMap.put("item_type", item_type);

			dataSourceListBlock1.add(hashMap);
			index = contextString.indexOf("item_type:", index) + 10;
		}

		for (int i = 0; i < 16; i++) {
			HashMap<String, Object> hashMap = new HashMap<String, Object>();
			String item_image = contextString.substring(contextString.indexOf("item_image:", index) + 11,
					contextString.indexOf(",item_text:", index)).trim();
			String item_text = contextString.substring(contextString.indexOf("item_text:", index) + 10,
					contextString.indexOf(",item_selected:", index)).trim();
			Boolean item_selected = Boolean.getBoolean(contextString.substring(
					contextString.indexOf("item_selected:", index) + 14, contextString.indexOf(",item_null:", index)));

			boolean item_null = false;
			if ("null".equals(contextString.substring(contextString.indexOf("item_null:", index) + 10,
					contextString.indexOf(",item_aisle:", index)))) {
				item_null = true;
				hashMap.put("item_null", item_null);
			} else {
				item_null = false;
				hashMap.put("item_null", item_null);
			}
			// = contextString.substring(
			// contextString.indexOf("item_null:", index) + 10,
			// contextString.indexOf(",item_aisle:", index));
			int item_aisle = 0;
			if ("null".equals(contextString.substring(contextString.indexOf("item_aisle:", index) + 11,
					contextString.indexOf(",item_type:", index)).trim())) {

			} else {
				item_aisle = Integer.parseInt(contextString.substring(contextString.indexOf("item_aisle:", index) + 11,
						contextString.indexOf(",item_type:", index)).trim());
			}

			// String item_type = contextString.substring(
			// contextString.indexOf("item_type:", index) + 11,
			// contextString.indexOf("item_type:", index));

			int nextIndex = contextString.indexOf("item_image:", index) + 11;

			String item_type = "";
			if (contextString.indexOf("item_image:", nextIndex) < 0) {

				// TODO 最后一位不出来颜色bug在这以后再改
				if ("Absolute Quantitation"
						.equals(SharedPreferencesUtils.get(AnalyzeRawDataActivity.this,
								BaseApplication.BASEINFORMATION_EXPERIMENTTYPE, ""))
						| "绝对定量".equals(SharedPreferencesUtils.get(AnalyzeRawDataActivity.this,
								BaseApplication.BASEINFORMATION_EXPERIMENTTYPE, ""))) {
					item_type = contextString.substring(contextString.indexOf("item_type:", index) + 10,
							contextString.indexOf(",,cameraSet", nextIndex)).trim();
				} else if ("Standard Curve Relative Quantitation"
						.equals(SharedPreferencesUtils.get(AnalyzeRawDataActivity.this,
								BaseApplication.BASEINFORMATION_EXPERIMENTTYPE, ""))
						| "标准曲线相对定量".equals(SharedPreferencesUtils.get(AnalyzeRawDataActivity.this,
								BaseApplication.BASEINFORMATION_EXPERIMENTTYPE, ""))) {
					item_type = contextString.substring(contextString.indexOf("item_type:", index) + 10,
							contextString.indexOf(",,endogenousControl", nextIndex)).trim();
				} else if ("⊿Ct Relative Quantitation"
						.equals(SharedPreferencesUtils.get(AnalyzeRawDataActivity.this,
								BaseApplication.BASEINFORMATION_EXPERIMENTTYPE, ""))
						| "比较ct值相对定量".equals(SharedPreferencesUtils.get(AnalyzeRawDataActivity.this,
								BaseApplication.BASEINFORMATION_EXPERIMENTTYPE, ""))) {
					item_type = contextString.substring(contextString.indexOf("item_type:", index) + 10,
							contextString.indexOf(",,endogenousControl", nextIndex)).trim();
				}
				// ByAlert.alert(contextString.substring(
				// contextString.indexOf("item_type:", index) + 10,
				// contextString.length()-1));
			} else {
				if (i == 15) {

				} else {
					item_type = contextString.substring(contextString.indexOf("item_type:", index) + 10,
							contextString.indexOf(",item_image:", nextIndex)).trim();
				}
			}

			LogUtil.e(item_image);
			LogUtil.e(item_text);
			LogUtil.e(item_selected);
			// LogUtil.e(item_null+"");
			// LogUtil.e(item_aisle+"");
			LogUtil.e(item_type);

			hashMap.put("item_image", item_image);
			hashMap.put("item_text", item_text);
			hashMap.put("item_selected", item_selected);

			hashMap.put("item_aisle", item_aisle);
			hashMap.put("item_type", item_type);

			dataSourceListBlock2.add(hashMap);
			index = contextString.indexOf("item_type:", index) + 10;

		}
		Gson gson = new Gson();
		String json = "";
		json = (String) SharedPreferencesUtils.get(AnalyzeRawDataActivity.this, "positionsArrayList", "");
		Type type = new TypeToken<HashSet<Integer>>() {
		}.getType();
		HashSet<Integer> positionsArrayList = new HashSet<Integer>();
		if (TextUtils.isEmpty(json)) {

		} else {
			positionsArrayList = gson.fromJson(json, type);
		}

		if (positionsArrayList != null) {
			for (int i : positionsArrayList) {
				if (i < 16) {
					HashMap<String, Object> hashMap = new HashMap<String, Object>();
					hashMap.put("item_image", "");
					hashMap.put("item_text", "");
					hashMap.put("item_selected", false);

					hashMap.put("item_aisle", 0);
					hashMap.put("item_type", "null");
					dataSourceListBlock1.set(i, hashMap);
				} else {
					HashMap<String, Object> hashMap = new HashMap<String, Object>();
					hashMap.put("item_image", "");
					hashMap.put("item_text", "");
					hashMap.put("item_selected", false);

					hashMap.put("item_aisle", 0);
					hashMap.put("item_type", "null");
					dataSourceListBlock2.set(i - 16, hashMap);
				}
			}
		}

	}

	@Override
	public void initDragGridView() {
		// dataSourceListBlock1 =
		// AnalyzeAmplificationplotActivity.getInstence().dataSourceListBlock1;
		// dataSourceListBlock2 =
		// AnalyzeAmplificationplotActivity.getInstence().dataSourceListBlock2;
		getDataSourListBlock();
		HashSet<Integer> positionsArrayList = new HashSet<Integer>();
		positionsArrayList = (HashSet<Integer>) SharedPreferencesUtils.get(AnalyzeRawDataActivity.this,
				"positionsArrayList", null);
		if (positionsArrayList != null) {
			for (int i : positionsArrayList) {
				if (i < 16) {
					HashMap<String, Object> hashMap = new HashMap<String, Object>();
					hashMap.put("item_image", "");
					hashMap.put("item_text", "");
					hashMap.put("item_selected", false);

					hashMap.put("item_aisle", 0);
					hashMap.put("item_type", "null");
					dataSourceListBlock1.set(i, hashMap);
				} else {
					HashMap<String, Object> hashMap = new HashMap<String, Object>();
					hashMap.put("item_image", "");
					hashMap.put("item_text", "");
					hashMap.put("item_selected", false);

					hashMap.put("item_aisle", 0);
					hashMap.put("item_type", "null");
					dataSourceListBlock2.set(i - 16, hashMap);
				}
			}
		}

		for (HashMap<String, Object> bean : dataSourceListBlock1) {
			bean.put("item_selected", false);

		}
		for (HashMap<String, Object> bean : dataSourceListBlock2) {
			bean.put("item_selected", false);

		}
		dataSourceListBlockToShow.addAll(dataSourceListBlock1);

		dragGridViewAdapter = new DragGridViewAdapter(dataSourceListBlockToShow);

		dragGridView.setAdapter(dragGridViewAdapter);
		dragGridView.setOnItemClickListener(new OnItemClickListener() {

			@Override
			public void onItemClick(AdapterView<?> arg0, View arg1, int position, long arg3) {

				// int seekBarSelectedNum = Integer.parseInt(numTv.getText() +
				// "");
				if ("block1".equals(blockStr)) {
					if ((Boolean) dataSourceListBlock1.get(position).get("item_selected")) {
						dataSourceListBlock1.get(position).put("item_selected", false);
						if (TextUtils.isEmpty(dataSourceListBlock1.get(position).get("item_image") + "")) {

						} else {

							upDateRemovelineData(position);
						}

					} else {
						dataSourceListBlock1.get(position).put("item_selected", true);
						if (TextUtils.isEmpty(dataSourceListBlock1.get(position).get("item_image") + "")) {

						} else {

							getlineData(position);
						}
					}

				} else if ("block2".equals(blockStr)) {
					if ((Boolean) dataSourceListBlock2.get(position).get("item_selected")) {
						dataSourceListBlock2.get(position).put("item_selected", false);
						if (TextUtils.isEmpty(dataSourceListBlock2.get(position).get("item_image") + "")) {

						} else {

							upDateRemovelineData(position + 16);
						}

					} else {

						dataSourceListBlock2.get(position).put("item_selected", true);
						if (TextUtils.isEmpty(dataSourceListBlock2.get(position).get("item_image") + "")) {

						} else {

							getlineData(position + 16);
						}

					}
				}

				dragGridViewAdapter.notifyDataSetChanged();

			}
		});

		block1Btn.setOnClickListener(new OnClickListener() {

			@Override
			public void onClick(View v) {
				blockUpTv.setText("A");
				blockDownTv.setText("B");

				block1Btn.setBackground(getResources().getDrawable(R.drawable.shape_darkblueblackframe));
				block2Btn.setBackground(getResources().getDrawable(R.drawable.shape_blackframe));

				dataSourceListBlockToShow.clear();
				dataSourceListBlockToShow.addAll(dataSourceListBlock1);
				dragGridViewAdapter.notifyDataSetChanged();

				blockStr = "block1";
			}
		});
		block2Btn.setOnClickListener(new OnClickListener() {

			@Override
			public void onClick(View v) {
				blockUpTv.setText("C");
				blockDownTv.setText("D");

				block1Btn.setBackground(getResources().getDrawable(R.drawable.shape_blackframe));
				block2Btn.setBackground(getResources().getDrawable(R.drawable.shape_darkblueblackframe));
				dataSourceListBlockToShow.clear();
				dataSourceListBlockToShow.addAll(dataSourceListBlock2);
				dragGridViewAdapter.notifyDataSetChanged();

				blockStr = "block2";
			}
		});
		LineData lineData = new LineData(xValues, dataSets);

		chart.setGridBackgroundColor(Color.WHITE);

		// 将数据插入
		chart.setData(lineData);
		Legend mLegend = chart.getLegend();
		// 设置比例图标示，就是那个一组y的value的 mLegend.setXEntrySpace(7f);
		mLegend.setYEntrySpace(5f);
		mLegend.setForm(LegendForm.CIRCLE);// 样式
		mLegend.setFormSize(0f);// 字体
		mLegend.setTextColor(Color.WHITE);// 颜色
		chart.animateX(0); // 立即执行的动画,x轴

	}

	@Override
	public void initSeekBar() {
		// 读取文件
		folderName = SharedPreferencesUtils.get(AnalyzeRawDataActivity.this,
				BaseApplication.FILEMANGER_PREPAREFOLDERPATH, "") + "";
		fileName = SharedPreferencesUtils.get(AnalyzeRawDataActivity.this, BaseApplication.FILEMANGER_PREPAREFILENAME,
				"") + "";

		String path = appFilePath + "/" + folderName;

		File file = new File(path + "/" + fileName);
		BufferedReader reader = null;
		contextString = new StringBuffer();
		try {
			System.out.println("以行为单位读取文件内容，一次读一整行：");
			reader = new BufferedReader(new FileReader(file));
			String tempString = null;
			int line = 1;
			// 一次读入一行，直到读入null为文件结束
			while ((tempString = reader.readLine()) != null) {
				// 显示行号
				// System.out.println("line " + line + ": " +
				// tempString);
				// Log.e("--", tempString);
				contextString.append(tempString);
				contextString.append(",");
				line++;
			}
			reader.close();
		} catch (IOException e) {
			e.printStackTrace();
		} finally {
			if (reader != null) {
				try {
					reader.close();
					// LogUtil.e("!!", contextString + "");

				} catch (IOException e1) {
				}
			}
		}

		// 获取具体哪一步需要
		int stepNum = Integer.parseInt(contextString
				.substring(contextString.indexOf(",readDataString: ") + 17, contextString.indexOf(",,Methods")).trim());
				// 获取数据集合

		// 下面解析
		int num = 1;
		int index = 0;
		String methodsStr;
		methodsStr = contextString.substring(contextString.indexOf("Methods,,"), contextString.indexOf(",,pointMap"));

		// for (int i = 0; i < 40; i++) {
		//
		// // x
		// itemHashMap.put("x", i);
		// // y
		// itemHashMap.put("y", "");
		// // 温度
		// itemHashMap.put("temperature", "");
		// // 时间
		// itemHashMap.put("time", "");
		// // DeltaT
		// itemHashMap.put("deltaT", "");
		// // gotTo
		// itemHashMap.put("goTo", "");
		// // Repititions
		// itemHashMap.put("repititions", "");
		//
		// }
		// pointmaps
		pointMaps = new ArrayList<HashMap<String, Object>>();
		int x = 0;
		while (methodsStr.indexOf("steptType:", index) >= 0) {
			HashMap<String, Object> itemHashMap = new HashMap<String, Object>();
			methodsStr.substring(methodsStr.indexOf("steptType", index) + 11,
					methodsStr.indexOf(",temperature", index));
			// x
			itemHashMap.put("x", x);
			// 温度
			itemHashMap.put("temperature", methodsStr.substring(methodsStr.indexOf("temperature", index) + 13,
					methodsStr.indexOf(",time:", index)));
			// time
			itemHashMap.put("time",
					methodsStr.substring(methodsStr.indexOf("time", index) + 6, methodsStr.indexOf(",goTo:", index)));
			// DeltaT
			itemHashMap.put("repititions", methodsStr.substring(methodsStr.indexOf("Repititions", index) + 13,
					methodsStr.indexOf(",deltaT: ", index)));
			// gotTo
			itemHashMap.put("goTo", methodsStr.substring(methodsStr.indexOf("goTo", index) + 6,
					methodsStr.indexOf(",Repititions: ", index)));

			// DeltaT
			itemHashMap.put("deltaT", methodsStr.substring(methodsStr.indexOf("deltaT", index) + 8,
					methodsStr.indexOf(",rightSelect:", index)));

			// 查看是不是最后一个
			if (methodsStr.indexOf(",steptType:", methodsStr.indexOf("steptType", index)) > 0) {
				// methodsStr.substring(
				// methodsStr.indexOf("rightSelect", index) + 13,
				// methodsStr.indexOf(",steptType:",
				// methodsStr.indexOf("steptType", index) + 11));

				//
				itemHashMap.put("rightSelect", methodsStr.substring(methodsStr.indexOf("rightSelect", index) + 13,
						methodsStr.indexOf(",steptType:", methodsStr.indexOf("steptType", index) + 11)));

			} else {
				// methodsStr.substring(
				// methodsStr.indexOf("rightSelect", index) + 13,
				// methodsStr.length());

				itemHashMap.put("rightSelect",
						methodsStr.substring(methodsStr.indexOf("rightSelect", index) + 13, methodsStr.length()));
			}
			index = methodsStr.indexOf(",rightSelect:", index) + 14;
			pointMaps.add(itemHashMap);
			x++;
		}
		rawdataUtil = new RawDataUtil(folderName, fileName, this);

		seekBarNum = rawdataUtil.getRepititions();
		if (seekBarNum == 0) {
			white_line.setVisibility(View.VISIBLE);
		} else if (seekBarNum == 1) {
			white_line.setVisibility(View.VISIBLE);
		}
		seekBar.setMax(seekBarNum - 1);

		folderName = SharedPreferencesUtils.get(AnalyzeRawDataActivity.this,
				BaseApplication.FILEMANGER_PREPAREFOLDERPATH, "") + "";
		fileName = SharedPreferencesUtils.get(AnalyzeRawDataActivity.this, BaseApplication.FILEMANGER_PREPAREFILENAME,
				"") + "";
		// fileParsingUtil = new FileParsingUtil(folderName, fileName);
		// fileParsingUtil.getExperimentData();

		seekBar.setOnSeekBarChangeListener(new OnSeekBarChangeListener() {

			@Override
			public void onStopTrackingTouch(SeekBar seekBar) {
				// TODO Auto-generated method stub

			}

			@Override
			public void onStartTrackingTouch(SeekBar seekBar) {
				// TODO Auto-generated method stub

			}

			@Override
			public void onProgressChanged(SeekBar seekBar, int progress, boolean fromUser) {
				numTv.setText(progress + 1 + "");

				dataSets.clear();

				// 先获取哪些基因盘被选中了
				for (int i = 0; i < 16; i++) {
					if ((Boolean) dataSourceListBlock1.get(i).get("item_selected")) {
						getlineData(i);

					}
					if ((Boolean) dataSourceListBlock2.get(i).get("item_selected")) {
						getlineData(i + 16);
					}
				}

			}

		});

		addTv.setOnClickListener(new OnClickListener() {

			@Override
			public void onClick(View v) {
				if (Integer.parseInt(numTv.getText().toString()) + 1 > seekBarNum) {

				} else {
					numTv.setText(Integer.parseInt(numTv.getText().toString()) + 1 + "");
					seekBar.setProgress(seekBar.getProgress() + 1);
				}
			}
		});
		subTv.setOnClickListener(new OnClickListener() {

			@Override
			public void onClick(View v) {

				if (Integer.parseInt(numTv.getText().toString()) - 1 < 1) {

				} else {
					numTv.setText(Integer.parseInt(numTv.getText().toString()) - 1 + "");
					seekBar.setProgress(seekBar.getProgress() - 1);
				}
			}
		});

	}

	// 设置actionBar
	public void setActionBar() {
		Button leftfirstBtn, leftsecondBtn, leftThirdBtn, leftForthBtn, leftFifthBtn, leftSixthBtn, leftSevenThBtn,
				leftEighthBtn, leftNinethBtn, leftTenth_btn;
		// TextView title;

		String ExperimentType = contextString.subSequence(contextString.indexOf("ExperimentType:") + 15,
				contextString.indexOf(",SampleType:")) + "";
		leftfirstBtn = BindView(R.id.leftfirst_btn);
		leftfirstBtn.setVisibility(View.VISIBLE);
		leftsecondBtn = BindView(R.id.leftsecond_btn);
		leftsecondBtn.setVisibility(View.VISIBLE);
		leftThirdBtn = BindView(R.id.leftThird_btn);
		leftThirdBtn.setVisibility(View.VISIBLE);
		leftForthBtn = BindView(R.id.leftForth_btn);
		leftForthBtn.setVisibility(View.VISIBLE);
		leftFifthBtn = BindView(R.id.leftFifth_btn);
		leftFifthBtn.setVisibility(View.VISIBLE);
		leftSixthBtn = BindView(R.id.leftSixth_btn);
		leftSixthBtn.setVisibility(View.VISIBLE);
		leftSevenThBtn = BindView(R.id.leftSevenTh_btn);
		leftSevenThBtn.setVisibility(View.VISIBLE);
		leftEighthBtn = BindView(R.id.leftEighth_btn);
		leftEighthBtn.setVisibility(View.VISIBLE);
		leftNinethBtn = BindView(R.id.leftNineth_btn);
		leftNinethBtn.setVisibility(View.VISIBLE);

		if (ExperimentType.equals("绝对定量") || ExperimentType.equals("Absolute Quantitation")) {
			leftTenth_btn = BindView(R.id.leftTenth_btn);
			leftTenth_btn.setVisibility(View.INVISIBLE);

			leftfirstBtn.setText(R.string.item_actionbar_home);
			leftsecondBtn.setText(R.string.ana_amplification);
			leftThirdBtn.setText(R.string.ana_standarad);
			leftForthBtn.setText(R.string.ana_multiplot);
			leftFifthBtn.setText(R.string.ana_rawdata);
			leftSixthBtn.setText(R.string.ana_meltcurve);
			leftSevenThBtn.setText(R.string.ana_result);
			leftEighthBtn.setText(R.string.ana_report);
			leftNinethBtn.setText(R.string.ana_analysissetting);

			leftFifthBtn.setSelected(true);

			leftThirdBtn.setOnClickListener(new OnClickListener() {

				@Override
				public void onClick(View v) {
					System.gc();
					pd = ProgressDialog.show(AnalyzeRawDataActivity.this, "", "loading...", true, true);

					new Thread() {
						public void run() {
							try {
								Intent intent = new Intent(AnalyzeRawDataActivity.this,
										AnalyzeStandardCurveActivity.class);
								startActivity(intent);
								finish();
							} finally {
								messageListener.sendEmptyMessage(TASK_LOOP_COMPLETE);
							}
						}
					}.start();
				}
			});
			leftForthBtn.setOnClickListener(new OnClickListener() {

				@Override
				public void onClick(View arg0) {
					System.gc();
					new Thread() {
						public void run() {
							try {
								Intent intent = new Intent(AnalyzeRawDataActivity.this,
										AnalyzeMulticomponentPlotActivity.class);
								startActivity(intent);
								finish();
							} finally {
								messageListener.sendEmptyMessage(TASK_LOOP_COMPLETE);
							}
						}
					}.start();

				}
			});
			leftFifthBtn.setOnClickListener(new OnClickListener() {

				@Override
				public void onClick(View arg0) {
					System.gc();
					pd = ProgressDialog.show(AnalyzeRawDataActivity.this, "", "loading...", true, true);

					new Thread() {
						public void run() {
							try {
								Intent intent = new Intent(AnalyzeRawDataActivity.this, AnalyzeRawDataActivity.class);
								startActivity(intent);
							} finally {
								messageListener.sendEmptyMessage(TASK_LOOP_COMPLETE);
							}
						}
					}.start();

				}
			});
			leftSixthBtn.setOnClickListener(new OnClickListener() {

				@Override
				public void onClick(View arg0) {
					System.gc();
					pd = ProgressDialog.show(AnalyzeRawDataActivity.this, "", "loading...", true, true);

					new Thread() {
						public void run() {
							try {
								Intent intent = new Intent(AnalyzeRawDataActivity.this, AnalyzeMeltCurveActivity.class);
								startActivity(intent);
								finish();
							} finally {
								messageListener.sendEmptyMessage(TASK_LOOP_COMPLETE);
							}
						}
					}.start();

				}
			});
			leftSevenThBtn.setOnClickListener(new OnClickListener() {

				@Override
				public void onClick(View arg0) {
					System.gc();
					pd = ProgressDialog.show(AnalyzeRawDataActivity.this, "", "loading...", true, true);

					new Thread() {
						public void run() {
							try {
								Intent intent = new Intent(AnalyzeRawDataActivity.this,
										AnalyzeRawDataTwoActivity.class);
								startActivity(intent);
								finish();
							} finally {
								messageListener.sendEmptyMessage(TASK_LOOP_COMPLETE);
							}
						}
					}.start();

				}
			});
			leftEighthBtn.setOnClickListener(new OnClickListener() {

				@Override
				public void onClick(View arg0) {
					System.gc();
					pd = ProgressDialog.show(AnalyzeRawDataActivity.this, "", "loading...", true, true);

					new Thread() {
						public void run() {
							try {
								Intent intent = new Intent(AnalyzeRawDataActivity.this, ReportActivity.class);
								startActivity(intent);
								finish();
							} finally {
								messageListener.sendEmptyMessage(TASK_LOOP_COMPLETE);
							}
						}
					}.start();

				}
			});
			leftNinethBtn.setOnClickListener(new OnClickListener() {

				@Override
				public void onClick(View arg0) {
					System.gc();
					pd = ProgressDialog.show(AnalyzeRawDataActivity.this, "", "loading...", true, true);

					new Thread() {
						public void run() {
							try {
								Intent intent = new Intent(AnalyzeRawDataActivity.this, ParameterSettingActivity.class);
								startActivity(intent);
								finish();
							} finally {
								messageListener.sendEmptyMessage(TASK_LOOP_COMPLETE);
							}
						}
					}.start();

				}
			});

		} else if (ExperimentType.equals("标准曲线相对定量") || ExperimentType.equals("Standard Curve Relative Quantitation")) {

			leftTenth_btn = BindView(R.id.leftTenth_btn);
			leftTenth_btn.setVisibility(View.VISIBLE);
			leftfirstBtn.setText(R.string.item_actionbar_home);
			leftsecondBtn.setText(R.string.ana_amplification);
			leftThirdBtn.setText(R.string.ana_standarad);
			leftForthBtn.setText(R.string.ana_multiplot);
			leftFifthBtn.setText(R.string.ana_rawdata);
			leftSixthBtn.setText(R.string.ana_meltcurve);
			leftSevenThBtn.setText(R.string.ana_rela_quan);
			leftEighthBtn.setText(R.string.ana_result);
			leftNinethBtn.setText(R.string.ana_report);
			leftTenth_btn.setText(R.string.ana_analysissetting);

			leftFifthBtn.setSelected(true);

			leftThirdBtn.setOnClickListener(new OnClickListener() {

				@Override
				public void onClick(View v) {
					System.gc();
					pd = ProgressDialog.show(AnalyzeRawDataActivity.this, "", "loading...", true, true);

					new Thread() {
						public void run() {
							try {
								Intent intent = new Intent(AnalyzeRawDataActivity.this,
										AnalyzeStandardCurveActivity.class);
								startActivity(intent);
								finish();
							} finally {
								messageListener.sendEmptyMessage(TASK_LOOP_COMPLETE);
							}
						}
					}.start();
				}
			});
			leftForthBtn.setOnClickListener(new OnClickListener() {

				@Override
				public void onClick(View arg0) {
					System.gc();
					new Thread() {
						public void run() {
							try {
								Intent intent = new Intent(AnalyzeRawDataActivity.this,
										AnalyzeMulticomponentPlotActivity.class);
								startActivity(intent);
								finish();
							} finally {
								messageListener.sendEmptyMessage(TASK_LOOP_COMPLETE);
							}
						}
					}.start();

				}
			});
			leftFifthBtn.setOnClickListener(new OnClickListener() {

				@Override
				public void onClick(View arg0) {
					System.gc();
					pd = ProgressDialog.show(AnalyzeRawDataActivity.this, "", "loading...", true, true);

					new Thread() {
						public void run() {
							try {
								Intent intent = new Intent(AnalyzeRawDataActivity.this, AnalyzeRawDataActivity.class);
								startActivity(intent);
							} finally {
								messageListener.sendEmptyMessage(TASK_LOOP_COMPLETE);
							}
						}
					}.start();

				}
			});
			leftSixthBtn.setOnClickListener(new OnClickListener() {

				@Override
				public void onClick(View arg0) {
					System.gc();
					pd = ProgressDialog.show(AnalyzeRawDataActivity.this, "", "loading...", true, true);

					new Thread() {
						public void run() {
							try {
								Intent intent = new Intent(AnalyzeRawDataActivity.this, AnalyzeMeltCurveActivity.class);
								startActivity(intent);
								finish();
							} finally {
								messageListener.sendEmptyMessage(TASK_LOOP_COMPLETE);
							}
						}
					}.start();

				}
			});
			leftSevenThBtn.setOnClickListener(new OnClickListener() {

				@Override
				public void onClick(View arg0) {
					System.gc();
					pd = ProgressDialog.show(AnalyzeRawDataActivity.this, "", "loading...", true, true);

					new Thread() {
						public void run() {
							try {
								Intent intent = new Intent(AnalyzeRawDataActivity.this,
										AnalyzeRelativeQuanticationActivity.class);
								startActivity(intent);
								finish();
							} finally {
								messageListener.sendEmptyMessage(TASK_LOOP_COMPLETE);
							}
						}
					}.start();

				}
			});
			leftEighthBtn.setOnClickListener(new OnClickListener() {

				@Override
				public void onClick(View arg0) {
					System.gc();
					pd = ProgressDialog.show(AnalyzeRawDataActivity.this, "", "loading...", true, true);

					new Thread() {
						public void run() {
							try {
								Intent intent = new Intent(AnalyzeRawDataActivity.this,
										AnalyzeRawDataTwoActivity.class);
								startActivity(intent);
								finish();
							} finally {
								messageListener.sendEmptyMessage(TASK_LOOP_COMPLETE);
							}
						}
					}.start();

				}
			});
			leftNinethBtn.setOnClickListener(new OnClickListener() {

				@Override
				public void onClick(View arg0) {
					System.gc();
					pd = ProgressDialog.show(AnalyzeRawDataActivity.this, "", "loading...", true, true);

					new Thread() {
						public void run() {
							try {
								Intent intent = new Intent(AnalyzeRawDataActivity.this, ReportActivity.class);
								startActivity(intent);
								finish();
							} finally {
								messageListener.sendEmptyMessage(TASK_LOOP_COMPLETE);
							}
						}
					}.start();

				}
			});
			leftTenth_btn.setOnClickListener(new OnClickListener() {

				@Override
				public void onClick(View v) {
					System.gc();
					pd = ProgressDialog.show(AnalyzeRawDataActivity.this, "", "loading...", true, true);

					new Thread() {
						public void run() {
							try {
								Intent intent = new Intent(AnalyzeRawDataActivity.this, ParameterSettingActivity.class);
								startActivity(intent);
								finish();
							} finally {
								messageListener.sendEmptyMessage(TASK_LOOP_COMPLETE);
							}
						}
					}.start();

				}
			});
		} else if (ExperimentType.equals("比较ct值相对定量") || ExperimentType.equals("⊿Ct Relative Quantitation")) {

			leftTenth_btn = BindView(R.id.leftTenth_btn);
			leftTenth_btn.setVisibility(View.VISIBLE);

			leftfirstBtn.setText(R.string.item_actionbar_home);
			leftsecondBtn.setText(R.string.ana_amplification);
			leftThirdBtn.setText(R.string.ana_multiplot);
			leftForthBtn.setText(R.string.ana_rawdata);
			leftFifthBtn.setText(R.string.ana_meltcurve);
			leftSixthBtn.setText(R.string.ana_rela_quan);
			leftSevenThBtn.setText(R.string.ana_result);
			leftEighthBtn.setText(R.string.ana_report);
			leftNinethBtn.setText(R.string.ana_analysissetting);

			leftForthBtn.setSelected(true);

			leftThirdBtn.setOnClickListener(new OnClickListener() {

				@Override
				public void onClick(View v) {
					System.gc();
					pd = ProgressDialog.show(AnalyzeRawDataActivity.this, "", "loading...", true, true);

					new Thread() {
						public void run() {
							try {
								Intent intent = new Intent(AnalyzeRawDataActivity.this,
										AnalyzeMulticomponentPlotActivity.class);
								startActivity(intent);
								finish();
							} finally {
								messageListener.sendEmptyMessage(TASK_LOOP_COMPLETE);
							}
						}
					}.start();
				}
			});
			leftForthBtn.setOnClickListener(new OnClickListener() {

				@Override
				public void onClick(View arg0) {
					System.gc();
					new Thread() {
						public void run() {
							try {
								Intent intent = new Intent(AnalyzeRawDataActivity.this, AnalyzeRawDataActivity.class);
								startActivity(intent);
							} finally {
								messageListener.sendEmptyMessage(TASK_LOOP_COMPLETE);
							}
						}
					}.start();

				}
			});
			leftFifthBtn.setOnClickListener(new OnClickListener() {

				@Override
				public void onClick(View arg0) {
					System.gc();
					pd = ProgressDialog.show(AnalyzeRawDataActivity.this, "", "loading...", true, true);

					new Thread() {
						public void run() {
							try {
								Intent intent = new Intent(AnalyzeRawDataActivity.this, AnalyzeMeltCurveActivity.class);
								startActivity(intent);
								finish();
							} finally {
								messageListener.sendEmptyMessage(TASK_LOOP_COMPLETE);
							}
						}
					}.start();

				}
			});
			leftSixthBtn.setOnClickListener(new OnClickListener() {

				@Override
				public void onClick(View arg0) {
					System.gc();
					pd = ProgressDialog.show(AnalyzeRawDataActivity.this, "", "loading...", true, true);

					new Thread() {
						public void run() {
							try {
								Intent intent = new Intent(AnalyzeRawDataActivity.this,
										AnalyzeRelativeQuanticationActivity.class);
								startActivity(intent);
								finish();
							} finally {
								messageListener.sendEmptyMessage(TASK_LOOP_COMPLETE);
							}
						}
					}.start();

				}
			});
			leftSevenThBtn.setOnClickListener(new OnClickListener() {

				@Override
				public void onClick(View arg0) {
					System.gc();
					pd = ProgressDialog.show(AnalyzeRawDataActivity.this, "", "loading...", true, true);

					new Thread() {
						public void run() {
							try {
								Intent intent = new Intent(AnalyzeRawDataActivity.this,
										AnalyzeRawDataTwoActivity.class);
								startActivity(intent);
								finish();
							} finally {
								messageListener.sendEmptyMessage(TASK_LOOP_COMPLETE);
							}
						}
					}.start();

				}
			});
			leftEighthBtn.setOnClickListener(new OnClickListener() {

				@Override
				public void onClick(View arg0) {
					System.gc();
					pd = ProgressDialog.show(AnalyzeRawDataActivity.this, "", "loading...", true, true);

					new Thread() {
						public void run() {
							try {
								Intent intent = new Intent(AnalyzeRawDataActivity.this, ReportActivity.class);
								startActivity(intent);
								finish();
							} finally {
								messageListener.sendEmptyMessage(TASK_LOOP_COMPLETE);
							}
						}
					}.start();

				}
			});
			leftNinethBtn.setOnClickListener(new OnClickListener() {

				@Override
				public void onClick(View arg0) {
					System.gc();
					pd = ProgressDialog.show(AnalyzeRawDataActivity.this, "", "loading...", true, true);

					new Thread() {
						public void run() {
							try {
								Intent intent = new Intent(AnalyzeRawDataActivity.this, ParameterSettingActivity.class);
								startActivity(intent);
								finish();
							} finally {
								messageListener.sendEmptyMessage(TASK_LOOP_COMPLETE);
							}
						}
					}.start();

				}
			});
			leftTenth_btn.setVisibility(View.INVISIBLE);

		}

		leftfirstBtn.setOnClickListener(new OnClickListener() {

			@Override
			public void onClick(View v) {
				System.gc();
				// pd = ProgressDialog.show(this, "", "loading...", true, true);
				pd = ProgressDialog.show(AnalyzeRawDataActivity.this, "", "loading...", true, true);

				new Thread() {
					public void run() {
						try {
							BaseApplication.getInstance().finishAll();
							Intent intent = new Intent(AnalyzeRawDataActivity.this, MainMenuActivity.class);
							startActivity(intent);
						} finally {
							messageListener.sendEmptyMessage(TASK_LOOP_COMPLETE);
						}
					}
				}.start();
				finish();

			}
		});
		leftsecondBtn.setOnClickListener(new OnClickListener() {

			@Override
			public void onClick(View v) {
				System.gc();
				pd = ProgressDialog.show(AnalyzeRawDataActivity.this, "", "loading...", true, true);

				new Thread() {
					public void run() {
						try {
							Intent intent = new Intent(AnalyzeRawDataActivity.this,
									AnalyzeAmplificationplotActivity.class);
							startActivity(intent);
							finish();
						} finally {
							messageListener.sendEmptyMessage(TASK_LOOP_COMPLETE);
						}
					}
				}.start();
			}
		});
		Boolean noRongJie=false;
		for(int i= 0; i<activityMethodBeans.size();i++){
			if(!TextUtils.isEmpty(activityMethodBeans.get(i).getDeltaT())){
				noRongJie=true;
			}
		}
		if(noRongJie){
			 if (getText(R.string.ana_meltcurve).equals(leftFifthBtn.getText())) {
				 leftFifthBtn.setVisibility(View.GONE);
			}else if (getText(R.string.ana_meltcurve).equals(leftSixthBtn.getText())) {
				leftSixthBtn.setVisibility(View.GONE);
			}
		}

	}

	// 获取当前时间的方法
	public void setSystemTime() {

		TextView date, fileName;
		date = BindView(R.id.date);
		fileName = BindView(R.id.file_name);

		// 获取系统时间
		SimpleDateFormat sdfDate = new SimpleDateFormat("MM dd,yyyy");
		date.setText(sdfDate.format(new Date()));

		// 文件路径置空
		fileName.setText(SharedPreferencesUtils.get(this, BaseApplication.FILEMANGER_PREPAREFOLDERPATH, "") + "/"
				+ SharedPreferencesUtils.get(this, BaseApplication.FILEMANGER_PREPAREFILENAME, ""));

	}

	// 设置bottom布局
	public void setBottomView() {
		Button bottomLeftFistBtn, bottomCenterBtn, bottomRightBtn;

		bottomLeftFistBtn = BindView(R.id.bottomLeftFistBtn);
		bottomCenterBtn = BindView(R.id.bottomCenterBtn);
		bottomRightBtn = BindView(R.id.bottomRightBtn);

		bottomLeftFistBtn.setVisibility(View.VISIBLE);
		// bottomCenterBtn.setVisibility(View.VISIBLE);
		bottomRightBtn.setVisibility(View.VISIBLE);

		bottomLeftFistBtn.setText(R.string.bottomView_back);
		// TODO 这个button的文字不确定暂时用A代替
		bottomCenterBtn.setText("A"); // 不确定！！！！！！！
		bottomRightBtn.setText(R.string.bottomView_next);

		bottomLeftFistBtn.setOnClickListener(new OnClickListener() {

			@Override
			public void onClick(View v) {
				// ByAlert.alert("back");
				pd = ProgressDialog.show(AnalyzeRawDataActivity.this, "", "loading...", true, true);

				new Thread() {
					public void run() {
						try {
							Intent intent = new Intent(AnalyzeRawDataActivity.this,
									AnalyzeMulticomponentPlotActivity.class);
							// intent.putStringArrayListExtra("data_list1",
							// data_list1);s
							startActivity(intent);
						} finally {
							messageListener.sendEmptyMessage(TASK_LOOP_COMPLETE);
						}
					}
				}.start();
				finish();

			}
		});

		bottomCenterBtn.setOnClickListener(new OnClickListener() {

			@Override
			public void onClick(View v) {
				ByAlert.alert("A");

			}
		});
		bottomRightBtn.setOnClickListener(new OnClickListener() {

			@Override
			public void onClick(View v) {
				System.gc();
				pd = ProgressDialog.show(AnalyzeRawDataActivity.this, "", "loading...", true, true);

				new Thread() {
					public void run() {
						try {
							Intent intent = new Intent(AnalyzeRawDataActivity.this, AnalyzeMeltCurveActivity.class);
							// intent.putStringArrayListExtra("data_list1",
							// data_list1);
							startActivity(intent);
							finish();
						} finally {
							messageListener.sendEmptyMessage(TASK_LOOP_COMPLETE);
						}
					}
				}.start();

			}
		});
	}

	// menu的弹出窗口
	private void showMenuPopupWindow(View v) {

		if (null == menuPopupWindow || !menuPopupWindow.isShowing()) {
			View contentView = LayoutInflater.from(this).inflate(R.layout.fragment_run_menu, null);

			menuPopupWindow = new PopupWindow(contentView, LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT);
			menuPopupWindow.setBackgroundDrawable(new BitmapDrawable());
			menuPopupWindow.setTouchable(true);
			menuPopupWindow.setOutsideTouchable(true);
			menuPopupWindow.showAsDropDown(v, -40, -3);

			TextView amplificationTv, temperatureTv, methodTv;
			amplificationTv = (TextView) contentView.findViewById(R.id.amplificationTv);
			temperatureTv = (TextView) contentView.findViewById(R.id.temperatureTv);
			methodTv = (TextView) contentView.findViewById(R.id.methodTv);

			amplificationTv.setBackground(getResources().getDrawable(R.color.darkBlue));
			amplificationTv.setTextColor(this.getResources().getColor(R.color.white));
			temperatureTv.setOnClickListener(new OnClickListener() {

				@Override
				public void onClick(View v) {

					menuPopupWindow.dismiss();
					Intent intent = new Intent(AnalyzeRawDataActivity.this, TemparetureActivity.class);
					startActivity(intent);

				}
			});
			methodTv.setOnClickListener(new OnClickListener() {

				@Override
				public void onClick(View v) {
					// Intent intent =new Intent(BaseInformationActivity, uri)
					menuPopupWindow.dismiss();
					Intent intent = new Intent(AnalyzeRawDataActivity.this, AnalyzeMulticomponentPlotActivity.class);
					startActivity(intent);
				}
			});

		} else {
			menuPopupWindow.dismiss();
			menuboo = !menuboo;
		}

	}

	public class DragGridViewAdapter extends BaseAdapter {
		List<HashMap<String, Object>> dataSourceListBlock = new ArrayList<HashMap<String, Object>>();

		public DragGridViewAdapter(List<HashMap<String, Object>> dataSourceListBlock) {
			super();
			this.dataSourceListBlock = dataSourceListBlock;
		}

		public void changeList(List<HashMap<String, Object>> dataSourceListBlock) {

			this.dataSourceListBlock = dataSourceListBlock;
			notifyDataSetChanged();
		}

		class ViewHolder {

			LinearLayout line, textViewLine;
			ImageView item_image;
			TextView item_text, aisle1, aisle2, aisle3, aisle4;

		}

		@Override
		public int getCount() {
			return dataSourceListBlock != null ? dataSourceListBlock.size() : 0;
		}

		@Override
		public Object getItem(int position) {
			return dataSourceListBlock != null ? dataSourceListBlock.get(position) : null;
		}

		@Override
		public long getItemId(int position) {
			return position;
		}

		@Override
		public View getView(int position, View convertView, ViewGroup parent) {
			final ViewHolder holder;
			if (convertView == null) {
				holder = new ViewHolder();
				convertView = LayoutInflater.from(AnalyzeRawDataActivity.this).inflate(R.layout.item_layout2_grid,
						null);

				holder.line = (LinearLayout) convertView.findViewById(R.id.line);
				holder.item_image = (ImageView) convertView.findViewById(R.id.item_image);
				holder.item_text = (TextView) convertView.findViewById(R.id.item_text);
				holder.aisle1 = (TextView) convertView.findViewById(R.id.aisle1);
				holder.aisle2 = (TextView) convertView.findViewById(R.id.aisle2);
				holder.aisle3 = (TextView) convertView.findViewById(R.id.aisle3);
				holder.aisle4 = (TextView) convertView.findViewById(R.id.aisle4);
				holder.textViewLine = (LinearLayout) convertView.findViewById(R.id.textViewLine);

				convertView.setTag(holder);
			} else {
				holder = (ViewHolder) convertView.getTag();
			}
			holder.aisle1.setVisibility(View.VISIBLE);
			holder.aisle2.setVisibility(View.VISIBLE);
			holder.aisle3.setVisibility(View.VISIBLE);
			holder.aisle4.setVisibility(View.VISIBLE);
			holder.textViewLine.setBackground(getResources().getDrawable(R.color.darkBlue));

			if (dataSourceListBlock.get(position).get("item_aisle") != null) {
				if (!TextUtils.isEmpty(dataSourceListBlock.get(position).get("item_aisle") + "")) {

					if (Integer.parseInt(dataSourceListBlock.get(position).get("item_aisle").toString()) != 0) {
						int aisleNum = (Integer) dataSourceListBlock.get(position).get("item_aisle");
						holder.textViewLine.setVisibility(View.VISIBLE);
						holder.aisle1.setVisibility(View.VISIBLE);
						holder.aisle2.setVisibility(View.VISIBLE);
						holder.aisle3.setVisibility(View.VISIBLE);
						holder.aisle4.setVisibility(View.VISIBLE);
						switch (aisleNum) {
						case 1:
							setcolor(holder.aisle1, position, holder.textViewLine);
							holder.aisle2.setBackground(getResources().getDrawable(R.color.white));
							holder.aisle3.setBackground(getResources().getDrawable(R.color.white));
							holder.aisle4.setBackground(getResources().getDrawable(R.color.white));

							break;
						case 2:
							holder.aisle1.setBackground(getResources().getDrawable(R.color.white));
							setcolor(holder.aisle2, position, holder.textViewLine);
							holder.aisle3.setBackground(getResources().getDrawable(R.color.white));
							holder.aisle4.setBackground(getResources().getDrawable(R.color.white));

							break;

						case 3:
							holder.aisle1.setBackground(getResources().getDrawable(R.color.white));
							holder.aisle2.setBackground(getResources().getDrawable(R.color.white));
							setcolor(holder.aisle3, position, holder.textViewLine);
							holder.aisle4.setBackground(getResources().getDrawable(R.color.white));
							break;

						case 4:
							holder.aisle1.setBackground(getResources().getDrawable(R.color.white));
							holder.aisle2.setBackground(getResources().getDrawable(R.color.white));
							holder.aisle3.setBackground(getResources().getDrawable(R.color.white));
							setcolor(holder.aisle4, position, holder.textViewLine);
							break;

						default:
							break;
						}
					} else {
						holder.textViewLine.setVisibility(View.INVISIBLE);
						holder.aisle1.setVisibility(View.INVISIBLE);
						holder.aisle2.setVisibility(View.INVISIBLE);
						holder.aisle3.setVisibility(View.INVISIBLE);
						holder.aisle4.setVisibility(View.INVISIBLE);
					}

				} else {
					holder.textViewLine.setVisibility(View.INVISIBLE);
					holder.aisle1.setVisibility(View.INVISIBLE);
					holder.aisle2.setVisibility(View.INVISIBLE);
					holder.aisle3.setVisibility(View.INVISIBLE);
					holder.aisle4.setVisibility(View.INVISIBLE);
				}
			}

			holder.line.setBackground(getResources().getDrawable(R.color.white));
			if (dataSourceListBlock.get(position).get("item_selected") != null) {

				if ((Boolean) dataSourceListBlock.get(position).get("item_selected")) {
					holder.line.setBackground(getResources().getDrawable(R.color.darkBlue));
				} else {
					holder.line.setBackground(getResources().getDrawable(R.color.white));
				}

			} else {
				holder.line.setBackground(getResources().getDrawable(R.color.white));
			}

			// map.put("item_type", "positive");

			if ("sample".equals(dataSourceListBlock.get(position).get("item_type"))) {
				holder.item_image.setBackgroundColor(Color.parseColor("#ff2d55"));
			} else if ("standard".equals(dataSourceListBlock.get(position).get("item_type"))) {
				holder.item_image.setBackgroundColor(Color.parseColor("#fd9727"));
			} else if ("positive".equals(dataSourceListBlock.get(position).get("item_type"))) {
				holder.item_image.setBackgroundColor(Color.parseColor("#ff00a9"));
			} else if ("negative".equals(dataSourceListBlock.get(position).get("item_type"))) {
				holder.item_image.setBackgroundColor(Color.parseColor("#159588"));
			} else if (dataSourceListBlock.get(position).get("item_image") == null) {
				holder.item_image.setBackground(getResources().getDrawable(R.color.white));
			} else if ("".equals(dataSourceListBlock.get(position).get("item_type"))) {
				holder.item_image.setBackground(getResources().getDrawable(R.color.white));
			} else {
				holder.item_image.setBackground(getResources().getDrawable(R.color.white));
			}

			// if
			// ("".equals(dataSourceListBlock.get(position).get("item_image")))
			// {
			// holder.item_image.setBackground(getResources().getDrawable(
			// R.color.white));
			// } else if ("11".equals(dataSourceListBlock.get(position).get(
			// "item_image"))) {
			// holder.item_image.setBackground(getResources().getDrawable(
			// R.color.palette_one_one));
			// } else if ("12".equals(dataSourceListBlock.get(position).get(
			// "item_image"))) {
			// holder.item_image.setBackground(getResources().getDrawable(
			// R.color.palette_one_two));
			// } else if ("13".equals(dataSourceListBlock.get(position).get(
			// "item_image"))) {
			// holder.item_image.setBackground(getResources().getDrawable(
			// R.color.palette_one_three));
			// } else if ("14".equals(dataSourceListBlock.get(position).get(
			// "item_image"))) {
			// holder.item_image.setBackground(getResources().getDrawable(
			// R.color.palette_one_four));
			// } else if ("15".equals(dataSourceListBlock.get(position).get(
			// "item_image"))) {
			// holder.item_image.setBackground(getResources().getDrawable(
			// R.color.palette_one_five));
			// } else if ("16".equals(dataSourceListBlock.get(position).get(
			// "item_image"))) {
			// holder.item_image.setBackground(getResources().getDrawable(
			// R.color.palette_one_six));
			// } else if ("21".equals(dataSourceListBlock.get(position).get(
			// "item_image"))) {
			// holder.item_image.setBackground(getResources().getDrawable(
			// R.color.palette_two_one));
			// } else if ("22".equals(dataSourceListBlock.get(position).get(
			// "item_image"))) {
			// holder.item_image.setBackground(getResources().getDrawable(
			// R.color.palette_two_two));
			// } else if ("23".equals(dataSourceListBlock.get(position).get(
			// "item_image"))) {
			// holder.item_image.setBackground(getResources().getDrawable(
			// R.color.palette_two_three));
			// } else if ("24".equals(dataSourceListBlock.get(position).get(
			// "item_image"))) {
			// holder.item_image.setBackground(getResources().getDrawable(
			// R.color.palette_two_four));
			// } else if ("25".equals(dataSourceListBlock.get(position).get(
			// "item_image"))) {
			// holder.item_image.setBackground(getResources().getDrawable(
			// R.color.palette_two_five));
			// } else if ("26".equals(dataSourceListBlock.get(position).get(
			// "item_image"))) {
			// holder.item_image.setBackground(getResources().getDrawable(
			// R.color.palette_two_six));
			// } else if ("31".equals(dataSourceListBlock.get(position).get(
			// "item_image"))) {
			// holder.item_image.setBackground(getResources().getDrawable(
			// R.color.palette_three_one));
			// } else if ("32".equals(dataSourceListBlock.get(position).get(
			// "item_image"))) {
			// holder.item_image.setBackground(getResources().getDrawable(
			// R.color.palette_three_two));
			// } else if ("33".equals(dataSourceListBlock.get(position).get(
			// "item_image"))) {
			// holder.item_image.setBackground(getResources().getDrawable(
			// R.color.palette_three_three));
			// } else if ("34".equals(dataSourceListBlock.get(position).get(
			// "item_image"))) {
			// holder.item_image.setBackground(getResources().getDrawable(
			// R.color.palette_three_four));
			// } else if ("35".equals(dataSourceListBlock.get(position).get(
			// "item_image"))) {
			// holder.item_image.setBackground(getResources().getDrawable(
			// R.color.palette_three_five));
			// } else if ("36".equals(dataSourceListBlock.get(position).get(
			// "item_image"))) {
			// holder.item_image.setBackground(getResources().getDrawable(
			// R.color.palette_three_six));
			// } else if ("41".equals(dataSourceListBlock.get(position).get(
			// "item_image"))) {
			// holder.item_image.setBackground(getResources().getDrawable(
			// R.color.palette_four_one));
			// } else if ("42".equals(dataSourceListBlock.get(position).get(
			// "item_image"))) {
			// holder.item_image.setBackground(getResources().getDrawable(
			// R.color.palette_four_two));
			// } else if ("43".equals(dataSourceListBlock.get(position).get(
			// "item_image"))) {
			// holder.item_image.setBackground(getResources().getDrawable(
			// R.color.palette_four_three));
			// } else if ("44".equals(dataSourceListBlock.get(position).get(
			// "item_image"))) {
			// holder.item_image.setBackground(getResources().getDrawable(
			// R.color.palette_four_four));
			// } else if ("45".equals(dataSourceListBlock.get(position).get(
			// "item_image"))) {
			// holder.item_image.setBackground(getResources().getDrawable(
			// R.color.palette_four_five));
			// } else if ("46".equals(dataSourceListBlock.get(position).get(
			// "item_image"))) {
			// holder.item_image.setBackground(getResources().getDrawable(
			// R.color.palette_four_six));
			// } else if ("51".equals(dataSourceListBlock.get(position).get(
			// "item_image"))) {
			// holder.item_image.setBackground(getResources().getDrawable(
			// R.color.palette_five_one));
			// } else if ("52".equals(dataSourceListBlock.get(position).get(
			// "item_image"))) {
			// holder.item_image.setBackground(getResources().getDrawable(
			// R.color.palette_five_two));
			// } else if ("53".equals(dataSourceListBlock.get(position).get(
			// "item_image"))) {
			// holder.item_image.setBackground(getResources().getDrawable(
			// R.color.palette_five_three));
			// } else if ("54".equals(dataSourceListBlock.get(position).get(
			// "item_image"))) {
			// holder.item_image.setBackground(getResources().getDrawable(
			// R.color.palette_five_four));
			// } else if ("55".equals(dataSourceListBlock.get(position).get(
			// "item_image"))) {
			// holder.item_image.setBackground(getResources().getDrawable(
			// R.color.palette_five_five));
			// } else if ("56".equals(dataSourceListBlock.get(position).get(
			// "item_image"))) {
			// holder.item_image.setBackground(getResources().getDrawable(
			// R.color.palette_five_six));
			// } else if ("61".equals(dataSourceListBlock.get(position).get(
			// "item_image"))) {
			// holder.item_image.setBackground(getResources().getDrawable(
			// R.color.palette_six_one));
			// } else if ("62".equals(dataSourceListBlock.get(position).get(
			// "item_image"))) {
			// holder.item_image.setBackground(getResources().getDrawable(
			// R.color.palette_six_two));
			// } else if ("63".equals(dataSourceListBlock.get(position).get(
			// "item_image"))) {
			// holder.item_image.setBackground(getResources().getDrawable(
			// R.color.palette_six_three));
			// } else if ("64".equals(dataSourceListBlock.get(position).get(
			// "item_image"))) {
			// holder.item_image.setBackground(getResources().getDrawable(
			// R.color.palette_six_four));
			// } else if ("65".equals(dataSourceListBlock.get(position).get(
			// "item_image"))) {
			// holder.item_image.setBackground(getResources().getDrawable(
			// R.color.palette_six_five));
			// } else if ("66".equals(dataSourceListBlock.get(position).get(
			// "item_image"))) {
			// holder.item_image.setBackground(getResources().getDrawable(
			// R.color.palette_six_six));
			// }
			holder.item_text.setText(dataSourceListBlock.get(position).get("item_text") + "");

			return convertView;
		}

		private void setcolor(TextView aisle, int position, LinearLayout textViewLine) {
			if ("".equals(dataSourceListBlock.get(position).get("item_image").toString().trim())) {
				aisle.setBackground(getResources().getDrawable(R.color.white));
				// textViewLine.setVisibility(View.INVISIBLE);
				textViewLine.setBackground(getResources().getDrawable(R.color.white));
			} else if ("11".equals(dataSourceListBlock.get(position).get("item_image"))) {
				aisle.setBackground(getResources().getDrawable(R.color.palette_one_one));
			} else if ("12".equals(dataSourceListBlock.get(position).get("item_image"))) {
				aisle.setBackground(getResources().getDrawable(R.color.palette_one_two));
			} else if ("13".equals(dataSourceListBlock.get(position).get("item_image"))) {
				aisle.setBackground(getResources().getDrawable(R.color.palette_one_three));
			} else if ("14".equals(dataSourceListBlock.get(position).get("item_image"))) {
				aisle.setBackground(getResources().getDrawable(R.color.palette_one_four));
			} else if ("15".equals(dataSourceListBlock.get(position).get("item_image"))) {
				aisle.setBackground(getResources().getDrawable(R.color.palette_one_five));
			} else if ("16".equals(dataSourceListBlock.get(position).get("item_image"))) {
				aisle.setBackground(getResources().getDrawable(R.color.palette_one_six));
			} else if ("21".equals(dataSourceListBlock.get(position).get("item_image"))) {
				aisle.setBackground(getResources().getDrawable(R.color.palette_two_one));
			} else if ("22".equals(dataSourceListBlock.get(position).get("item_image"))) {
				aisle.setBackground(getResources().getDrawable(R.color.palette_two_two));
			} else if ("23".equals(dataSourceListBlock.get(position).get("item_image"))) {
				aisle.setBackground(getResources().getDrawable(R.color.palette_two_three));
			} else if ("24".equals(dataSourceListBlock.get(position).get("item_image"))) {
				aisle.setBackground(getResources().getDrawable(R.color.palette_two_four));
			} else if ("25".equals(dataSourceListBlock.get(position).get("item_image"))) {
				aisle.setBackground(getResources().getDrawable(R.color.palette_two_five));
			} else if ("26".equals(dataSourceListBlock.get(position).get("item_image"))) {
				aisle.setBackground(getResources().getDrawable(R.color.palette_two_six));
			} else if ("31".equals(dataSourceListBlock.get(position).get("item_image"))) {
				aisle.setBackground(getResources().getDrawable(R.color.palette_three_one));
			} else if ("32".equals(dataSourceListBlock.get(position).get("item_image"))) {
				aisle.setBackground(getResources().getDrawable(R.color.palette_three_two));
			} else if ("33".equals(dataSourceListBlock.get(position).get("item_image"))) {
				aisle.setBackground(getResources().getDrawable(R.color.palette_three_three));
			} else if ("34".equals(dataSourceListBlock.get(position).get("item_image"))) {
				aisle.setBackground(getResources().getDrawable(R.color.palette_three_four));
			} else if ("35".equals(dataSourceListBlock.get(position).get("item_image"))) {
				aisle.setBackground(getResources().getDrawable(R.color.palette_three_five));
			} else if ("36".equals(dataSourceListBlock.get(position).get("item_image"))) {
				aisle.setBackground(getResources().getDrawable(R.color.palette_three_six));
			} else if ("41".equals(dataSourceListBlock.get(position).get("item_image"))) {
				aisle.setBackground(getResources().getDrawable(R.color.palette_four_one));
			} else if ("42".equals(dataSourceListBlock.get(position).get("item_image"))) {
				aisle.setBackground(getResources().getDrawable(R.color.palette_four_two));
			} else if ("43".equals(dataSourceListBlock.get(position).get("item_image"))) {
				aisle.setBackground(getResources().getDrawable(R.color.palette_four_three));
			} else if ("44".equals(dataSourceListBlock.get(position).get("item_image"))) {
				aisle.setBackground(getResources().getDrawable(R.color.palette_four_four));
			} else if ("45".equals(dataSourceListBlock.get(position).get("item_image"))) {
				aisle.setBackground(getResources().getDrawable(R.color.palette_four_five));
			} else if ("46".equals(dataSourceListBlock.get(position).get("item_image"))) {
				aisle.setBackground(getResources().getDrawable(R.color.palette_four_six));
			} else if ("51".equals(dataSourceListBlock.get(position).get("item_image"))) {
				aisle.setBackground(getResources().getDrawable(R.color.palette_five_one));
			} else if ("52".equals(dataSourceListBlock.get(position).get("item_image"))) {
				aisle.setBackground(getResources().getDrawable(R.color.palette_five_two));
			} else if ("53".equals(dataSourceListBlock.get(position).get("item_image"))) {
				aisle.setBackground(getResources().getDrawable(R.color.palette_five_three));
			} else if ("54".equals(dataSourceListBlock.get(position).get("item_image"))) {
				aisle.setBackground(getResources().getDrawable(R.color.palette_five_four));
			} else if ("55".equals(dataSourceListBlock.get(position).get("item_image"))) {
				aisle.setBackground(getResources().getDrawable(R.color.palette_five_five));
			} else if ("56".equals(dataSourceListBlock.get(position).get("item_image"))) {
				aisle.setBackground(getResources().getDrawable(R.color.palette_five_six));
			} else if ("61".equals(dataSourceListBlock.get(position).get("item_image"))) {
				aisle.setBackground(getResources().getDrawable(R.color.palette_six_one));
			} else if ("62".equals(dataSourceListBlock.get(position).get("item_image"))) {
				aisle.setBackground(getResources().getDrawable(R.color.palette_six_two));
			} else if ("63".equals(dataSourceListBlock.get(position).get("item_image"))) {
				aisle.setBackground(getResources().getDrawable(R.color.palette_six_three));
			} else if ("64".equals(dataSourceListBlock.get(position).get("item_image"))) {
				aisle.setBackground(getResources().getDrawable(R.color.palette_six_four));
			} else if ("65".equals(dataSourceListBlock.get(position).get("item_image"))) {
				aisle.setBackground(getResources().getDrawable(R.color.palette_six_five));
			} else if ("66".equals(dataSourceListBlock.get(position).get("item_image"))) {
				aisle.setBackground(getResources().getDrawable(R.color.palette_six_six));
			} else if (dataSourceListBlock.get(position).get("item_image") == null) {
				aisle.setBackground(getResources().getDrawable(R.color.white));
				// textViewLine.setVisibility(View.INVISIBLE);

			} else {
				aisle.setBackground(getResources().getDrawable(R.color.white));
				// textViewLine.setVisibility(View.INVISIBLE);
				aisle.setBackground(getResources().getDrawable(R.color.white));
			}

		}
	}

	@Override
	public void onClick(View v) {
		switch (v.getId()) {
		case R.id.showTv:
			if (showBoolean) {
				blockLine.setVisibility(View.INVISIBLE);
				geneLine.setVisibility(View.INVISIBLE);
				toolLine.setVisibility(View.VISIBLE);
				showTv.setBackground(getResources().getDrawable(R.drawable.shape_darkblueblackframe));
				showTv.setTextColor(Color.parseColor("#ffffff"));
			} else {
				blockLine.setVisibility(View.VISIBLE);
				geneLine.setVisibility(View.VISIBLE);
				toolLine.setVisibility(View.INVISIBLE);
				showTv.setBackground(getResources().getDrawable(R.drawable.shape_blackframe));
				showTv.setTextColor(Color.parseColor("#000000"));
			}
			showBoolean = !showBoolean;
			break;

		default:
			break;
		}

	}

	private void getlineData(int i) {

		ArrayList<Entry> yValues = new ArrayList<Entry>();
		if ("NaN".equals(rawdataUtil.getDataListArrayList().get(i).get(0)
				.getYValForXIndex(Integer.parseInt(numTv.getText().toString()) - 1) + "")) {
			yValues.add(new Entry(0, 0));

		} else {
			yValues.add(new Entry(rawdataUtil.getDataListArrayList().get(i).get(0)
					.getYValForXIndex(Integer.parseInt(numTv.getText().toString()) - 1), 0));
		}
		if ("NaN".equals(rawdataUtil.getDataListArrayList().get(i).get(1)
				.getYValForXIndex(Integer.parseInt(numTv.getText().toString()) - 1) + "")) {
			yValues.add(new Entry(0, 1));
		} else {
			yValues.add(new Entry(rawdataUtil.getDataListArrayList().get(i).get(1)
					.getYValForXIndex(Integer.parseInt(numTv.getText().toString()) - 1), 1));
		}

		if ("NaN".equals(rawdataUtil.getDataListArrayList().get(i).get(2)
				.getYValForXIndex(Integer.parseInt(numTv.getText().toString()) - 1) + "")) {
			yValues.add(new Entry(0, 2));
		} else {
			yValues.add(new Entry(rawdataUtil.getDataListArrayList().get(i).get(2)
					.getYValForXIndex(Integer.parseInt(numTv.getText().toString()) - 1), 2));
		}

		if ("NaN".equals(rawdataUtil.getDataListArrayList().get(i).get(3)
				.getYValForXIndex(Integer.parseInt(numTv.getText().toString()) - 1) + "")) {
			yValues.add(new Entry(0, 3));
		} else {
			yValues.add(new Entry(rawdataUtil.getDataListArrayList().get(i).get(3)
					.getYValForXIndex(Integer.parseInt(numTv.getText().toString()) - 1), 3));

		}

		dataSet = new LineDataSet(yValues, "");
		dataSet.setColor(color.red);
		dataSet.setCircleSize(0);
		dataSet.setValueTextSize(0);
		dataSet.setLineWidth(1);

		dataSets.add(dataSet);

		LineData lineData = new LineData(xValues, dataSets);

		chart.setGridBackgroundColor(Color.WHITE);

		// 将数据插入
		chart.setData(lineData);
		Legend mLegend = chart.getLegend();
		// 设置比例图标示，就是那个一组y的value的 mLegend.setXEntrySpace(7f);
		mLegend.setYEntrySpace(5f);
		mLegend.setForm(LegendForm.CIRCLE);// 样式
		mLegend.setFormSize(0f);// 字体
		mLegend.setTextColor(Color.WHITE);// 颜色
		chart.animateX(0); // 立即执行的动画,x轴

	}

	private void upDateRemovelineData(int i) {

		ArrayList<Entry> yValues = new ArrayList<Entry>();
		if ("NaN".equals(rawdataUtil.getDataListArrayList().get(i).get(0)
				.getYValForXIndex(Integer.parseInt(numTv.getText().toString()) - 1) + "")) {
			yValues.add(new Entry(0, 0));

		} else {
			yValues.add(new Entry(rawdataUtil.getDataListArrayList().get(i).get(0)
					.getYValForXIndex(Integer.parseInt(numTv.getText().toString()) - 1), 0));
		}
		if ("NaN".equals(rawdataUtil.getDataListArrayList().get(i).get(1)
				.getYValForXIndex(Integer.parseInt(numTv.getText().toString()) - 1) + "")) {
			yValues.add(new Entry(0, 1));
		} else {
			yValues.add(new Entry(rawdataUtil.getDataListArrayList().get(i).get(1)
					.getYValForXIndex(Integer.parseInt(numTv.getText().toString()) - 1), 1));
		}

		if ("NaN".equals(rawdataUtil.getDataListArrayList().get(i).get(2)
				.getYValForXIndex(Integer.parseInt(numTv.getText().toString()) - 1) + "")) {
			yValues.add(new Entry(0, 2));
		} else {
			yValues.add(new Entry(rawdataUtil.getDataListArrayList().get(i).get(2)
					.getYValForXIndex(Integer.parseInt(numTv.getText().toString()) - 1), 2));
		}

		if ("NaN".equals(rawdataUtil.getDataListArrayList().get(i).get(3)
				.getYValForXIndex(Integer.parseInt(numTv.getText().toString()) - 1) + "")) {
			yValues.add(new Entry(0, 3));
		} else {
			yValues.add(new Entry(rawdataUtil.getDataListArrayList().get(i).get(3)
					.getYValForXIndex(Integer.parseInt(numTv.getText().toString()) - 1), 3));

		}
		dataSet = new LineDataSet(yValues, "");
		dataSet.setColor(color.red);
		dataSet.setCircleSize(0);
		dataSet.setValueTextSize(0);
		dataSet.setLineWidth(1);

		for (int x = 0; x < dataSets.size(); x++) {
			if (dataSet.toString().equals(dataSets.get(x).toString())) {
				dataSets.remove(x);
				break;
			}
		}

		LineData lineData = new LineData(xValues, dataSets);

		chart.setGridBackgroundColor(Color.WHITE);

		// 将数据插入
		chart.setData(lineData);
		Legend mLegend = chart.getLegend();
		// 设置比例图标示，就是那个一组y的value的 mLegend.setXEntrySpace(7f);
		mLegend.setYEntrySpace(5f);
		mLegend.setForm(LegendForm.CIRCLE);// 样式
		mLegend.setFormSize(0f);// 字体
		mLegend.setTextColor(Color.WHITE);// 颜色
		chart.animateX(0); // 立即执行的动画,x轴

	}

	private Handler messageListener = new Handler() {
		public void handleMessage(Message msg) {
			switch (msg.arg1) {
			case TASK_LOOP_COMPLETE:
				try {
					pd.dismiss();
				} catch (Exception e) {
					// TODO: handle exception
				}

				break;

			}
		}
	};
	private int seekBarNum;

	// 配置数字键盘的popupwindow
	private void numberKeyBoardPopupWindow(View v, final TextView textv, Boolean type) {

		View conteView = LayoutInflater.from(this).inflate(R.layout.item_numkeyboard_method, null);

		final EditText showTv;
		TextView num0Tv, num1Tv, num2Tv, num3Tv, num4Tv, num5Tv, num6Tv, num7Tv, num8Tv, num9Tv, num10Tv, cancelTv,
				confirmTv, delTv;
		showTv = (EditText) conteView.findViewById(R.id.showTv);
		num0Tv = (TextView) conteView.findViewById(R.id.num0Tv);
		num1Tv = (TextView) conteView.findViewById(R.id.num1Tv);
		num2Tv = (TextView) conteView.findViewById(R.id.num2Tv);
		num3Tv = (TextView) conteView.findViewById(R.id.num3Tv);
		num4Tv = (TextView) conteView.findViewById(R.id.num4Tv);
		num5Tv = (TextView) conteView.findViewById(R.id.num5Tv);
		num6Tv = (TextView) conteView.findViewById(R.id.num6Tv);
		num7Tv = (TextView) conteView.findViewById(R.id.num7Tv);
		num8Tv = (TextView) conteView.findViewById(R.id.num8Tv);
		num9Tv = (TextView) conteView.findViewById(R.id.num9Tv);
		confirmTv = (TextView) conteView.findViewById(R.id.confirmTv);
		cancelTv = (TextView) conteView.findViewById(R.id.cancelTv);
		delTv = (TextView) conteView.findViewById(R.id.delTv);

		final PopupWindow numberKeyBoardPopupWindow = new PopupWindow(conteView, LayoutParams.WRAP_CONTENT,
				LayoutParams.WRAP_CONTENT, true);

		confirmTv.setOnClickListener(new OnClickListener() {

			@Override
			public void onClick(View v) {

				if (Integer.parseInt(showTv.getText().toString()) > seekBarNum) {
					ByAlert.alert(getString(R.string.rawdata_range));
					return;
				}
				if (Integer.parseInt(showTv.getText().toString()) < 1) {
					ByAlert.alert(getString(R.string.rawdata_range));
					return;
				}

				textv.setText(showTv.getText());
				numberKeyBoardPopupWindow.dismiss();
				seekBar.setProgress(Integer.parseInt(showTv.getText().toString()));

			}
		});

		if (type) {
			cancelTv.setOnClickListener(new OnClickListener() {

				@Override
				public void onClick(View v) {
					showTv.setText(showTv.getText().append("."));
					Selection.setSelection(showTv.getText(), showTv.getText().length());

				}
			});
		} else {
			numberKeyBoardPopupWindow.dismiss();
		}

		delTv.setOnClickListener(new OnClickListener() {

			@Override
			public void onClick(View v) {
				if (!TextUtils.isEmpty(showTv.getText().toString())) {
					showTv.setText(showTv.getText().toString().substring(0, showTv.getText().toString().length() - 1));
					Selection.setSelection(showTv.getText(), showTv.getText().length());
				}

			}
		});
		num0Tv.setOnClickListener(new OnClickListener() {

			@Override
			public void onClick(View v) {
				showTv.setText(showTv.getText().append("0"));
				Selection.setSelection(showTv.getText(), showTv.getText().length());

			}
		});
		num1Tv.setOnClickListener(new OnClickListener() {

			@Override
			public void onClick(View v) {
				showTv.setText(showTv.getText().append("1"));
				Selection.setSelection(showTv.getText(), showTv.getText().length());

			}
		});

		num2Tv.setOnClickListener(new OnClickListener() {

			@Override
			public void onClick(View v) {
				showTv.setText(showTv.getText().append("2"));
				Selection.setSelection(showTv.getText(), showTv.getText().length());

			}
		});
		num3Tv.setOnClickListener(new OnClickListener() {

			@Override
			public void onClick(View v) {
				showTv.setText(showTv.getText().append("3"));
				Selection.setSelection(showTv.getText(), showTv.getText().length());

			}
		});

		num3Tv.setOnClickListener(new OnClickListener() {

			@Override
			public void onClick(View v) {
				showTv.setText(showTv.getText().append("3"));
				Selection.setSelection(showTv.getText(), showTv.getText().length());

			}
		});
		num4Tv.setOnClickListener(new OnClickListener() {

			@Override
			public void onClick(View v) {
				showTv.setText(showTv.getText().append("4"));
				Selection.setSelection(showTv.getText(), showTv.getText().length());

			}
		});
		num5Tv.setOnClickListener(new OnClickListener() {

			@Override
			public void onClick(View v) {
				showTv.setText(showTv.getText().append("5"));
				Selection.setSelection(showTv.getText(), showTv.getText().length());

			}
		});

		num6Tv.setOnClickListener(new OnClickListener() {

			@Override
			public void onClick(View v) {
				showTv.setText(showTv.getText().append("6"));
				Selection.setSelection(showTv.getText(), showTv.getText().length());

			}
		});

		num7Tv.setOnClickListener(new OnClickListener() {

			@Override
			public void onClick(View v) {
				showTv.setText(showTv.getText().append("7"));
				Selection.setSelection(showTv.getText(), showTv.getText().length());

			}
		});
		num8Tv.setOnClickListener(new OnClickListener() {

			@Override
			public void onClick(View v) {
				showTv.setText(showTv.getText().append("8"));
				Selection.setSelection(showTv.getText(), showTv.getText().length());

			}
		});

		num9Tv.setOnClickListener(new OnClickListener() {

			@Override
			public void onClick(View v) {
				showTv.setText(showTv.getText().append("9"));
				Selection.setSelection(showTv.getText(), showTv.getText().length());

			}
		});

		numberKeyBoardPopupWindow.setTouchable(true);

		numberKeyBoardPopupWindow.setTouchInterceptor(new OnTouchListener() {

			@Override
			public boolean onTouch(View v, MotionEvent event) {

				// if (R.id.hourTv == textv.getId()) {
				// minuteTv.setBackground(getResources().getDrawable(
				// R.drawable.shape_blackframe));
				// textv.setBackground(getResources().getDrawable(
				// R.drawable.shape_darkblueblackframe));
				// } else if (R.id.minuteTv == textv.getId()) {
				//
				// minuteTv.setBackground(getResources().getDrawable(
				// R.drawable.shape_blackframe));
				// secondTv.setBackground(getResources().getDrawable(
				// R.drawable.shape_darkblueblackframe));
				//
				// } else if (R.id.secondTv == textv.getId()) {
				//
				// secondTv.setBackground(getResources().getDrawable(
				// R.drawable.shape_blackframe));
				// }
				return false;
				// 这里如果返回true的话，touch事件将被拦截
				// 拦截后 PopupWindow的onTouchEvent不被调用，这样点击外部区域无法dismiss
			}

		});

		numberKeyBoardPopupWindow.setBackgroundDrawable(new BitmapDrawable());
		numberKeyBoardPopupWindow.setTouchable(true);
		numberKeyBoardPopupWindow.setOutsideTouchable(true);
		numberKeyBoardPopupWindow.showAtLocation(v, Gravity.CENTER, 0, 0);

	}
}
